﻿$(function(){

    $('#loginMask input').placeholder();
	$('#loginMask button[action=login]').click(function(){
	    var userName = $('#loginMask input[name=userName]').val();
		var pwd = $('#loginMask input[name=pwd]').val();
		CloudDisk.Admin.SessionMgr.login(userName, pwd, function(){
		    $('#loginMask').hide();
				var currentTab = CloudDisk.Util.getUrlParameter('tab');
				if(currentTab){
					CloudDisk.Admin.AdminBoard.setActiveTab(currentTab);
				} else {
					CloudDisk.Admin.AdminBoard.setActiveTab('profile');
				}
		});
	});
	
	if(CloudDisk.Admin.SessionMgr.isLoggedIn()){
	    $('#loginMask').hide();
	}
    CloudDisk.Admin.AdminBoard.init();

	
	//implement a hash based navigation
	$(window).on('hashchange', function() {
        CloudDisk.Admin.AdminBoard.setActiveTab(CloudDisk.Util.getUrlParameter('tab'));
    });
	

	
	//for test
	//CloudDisk.Admin.SessionMgr.login('admin', '123456');
});